package com.kkarma.vo;

import com.alibaba.fastjson.annotation.JSONField;
import com.kkarma.pojo.MmsManager;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.Date;
import java.util.Set;

/**
 * @Author: karma
 * @Date: 2022/3/29 0029 - 03 - 29 - 18:21
 * @Description: com.kkarma.vo
 * @version: 1.0
 */
public class LoginUser implements UserDetails {

    private String token;

    private Long managerId;

    private Integer deptId;

    private MmsManager manager;

    private Set<String> permissions;

    private Long loginTime;

    private Long expireTime;

    public LoginUser(Long managerId, Integer deptId, MmsManager mmsManager) {
        this.managerId = managerId;
        this.deptId = deptId;
        this.manager = mmsManager;
    }

    public Long getLoginTime() {
        return loginTime;
    }

    public void setLoginTime(Long loginTime) {
        this.loginTime = loginTime;
    }

    public Long getExpireTime() {
        return expireTime;
    }

    public void setExpireTime(Long expireTime) {
        this.expireTime = expireTime;
    }

    public Integer getDeptId() {
        return deptId;
    }

    public void setDeptId(Integer deptId) {
        this.deptId = deptId;
    }

    public Long getManagerId() {
        return managerId;
    }

    public void setManagerId(Long managerId) {
        this.managerId = managerId;
    }

    public MmsManager getManager() {
        return manager;
    }

    public void setManager(MmsManager manager) {
        this.manager = manager;
    }

    public Set<String> getPermissions() {
        return permissions;
    }

    public void setPermissions(Set<String> permissions) {
        this.permissions = permissions;
    }

    @JSONField(serialize = false)
    @Override
    public String getPassword() {
        return manager.getPassword();
    }

    @Override
    public String getUsername() {
        return manager.getManagerName();
    }

    @JSONField(serialize = false)
    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @JSONField(serialize = false)
    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @JSONField(serialize = false)
    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @JSONField(serialize = false)
    @Override
    public boolean isEnabled() {
        return true;
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    public void setToken(String token) {
    }

    public String getToken() {
        return token;
    }
}
